<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>项目管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="${base}/css/bootstrap.css">
<script type="text/javascript" src="${base}/js/jquery-3.1.0.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.js"></script>
<!-- alan_18.2.28_解决密码修改不了 -->
<script type="text/javascript">
		var a1 = $("#userName").val();
		var a2 = $("#oldPassword").val();
		var a3 = $("#newPassword").val();
		var a4 = $("#rePassword").val();

		$(function(){
			
			
			if(a1 == "" ||a2 == "" ||a3 == "" ||a4 == "" ){
				$("#sChange").attr("disabled",true);
			}
			
			$("#oldPassword").blur(function(){
				var userName = $("#userName").val();
				var password = $(this).val();
				
				if(userName != ""){
					$.post("${ pageContext.request.contextPath }/user/checkPassword",{"userName":userName,"password":password},function(data){
						
		 				if(data == 1){
		 					 $("#s2").html("<font color='green'> </font>"); 
		 					$("#sChange").attr("disabled",false);
		 				}else if(data == 2){
		 					$("#s2").html("<font color='red'>您输入的密码不正确</font>");
		 					$("#sChange").attr("disabled",true);
			 			}
			 		});
				}else{
						$("#s2").html("<font color='red'>原密码不能为空</font>");
						$("#sChange").attr("disabled",true);
				}
			});
			
			$("#rePassword").blur(function(){
				var password = $("#newPassword").val();
				var rePassword = $(this).val();
				
				
				if(password != rePassword){
					$("#s4").html("<font color='red'>两次密码输入不一致</font>");
					$("#sChange").attr("disabled",true);
				}else{
					$("#s4").html("<font color='red'></font>");
					$("#sChange").attr("disabled",false);
				}
			});
			
			
				
		});
		
		

		function changePassword(){
			if(a3 == "" ){
				alert("请输入要修改的密码");
			}else{
			
				$.ajax({  
			        type: "POST",  
			        url:"${ pageContext.request.contextPath }/user/changePassword",  
			        data:$('#myForm').serialize(),// 序列化表单值  
			        dataType: "json",
			        success: function (data) {
			            alert("修改密码成功");
			           
					},
					async: true,
					cache: false
					}); 
			}
		}

	function deleteProject(obj) {
	    
	    var param = "projectId=" + obj;
	    if (confirm("确认删除"+param+"吗？")){
			$.ajax({
				url: "${base}/project/delete",
				data: {projectId:obj},
				dataType: "json",
				type: "POST",
				success: function (data) {
					
					 location.reload(); 
				},
				async: true,
				cache: false
				});
	    }
	}
	
	
	$(".tr").bind("mouseover", function() {
		$(this).css("background-color", "#eeeeee");
	})
	$(".tr").bind("mouseout", function() {
		$(this).css("background-color", "#ffffff");
	})
</script>
</head>

<body>
	<div class="container">
		<jsp:include page="${path}/menu.jsp"></jsp:include>
		<div style="margin-left: 20px;margin-bottom: 10px; color: grey">当前位置：个人中心</div>
		
		<div class="container-fluid">
			<div class="row-fluid">
				<div><button type="button" class="btn btn-primary" style="width: 160px">用户名: ${user.userName }</button>
				<a><button type="button" class="btn btn-primary" style="width: 160px;">姓名:${user.name }</button></a>
				<a><button type="button" class="btn btn-primary" style="width: 160px;" data-toggle="modal"
							data-target="#myModal">密码修改</button></a></div>
				<div style="padding-top: 20px"><a><button type="button" class="btn btn-primary" style="width: 180px;background-color: gray;">关注列表</button></a></div>
				
				<form method="post" action="" class="form-horizontal" role="form"
							id="myForm" onsubmit="return ">
							<div class="modal fade" id="myModal" role="dialog" tabindex=-1
								aria-labelledby="myModalLabel" aria-hidden="true">
								<!--  定义模态框，过渡效果为淡入，id为myModal,tabindex=-1可以禁用使用tab切换，aria-labelledby用于引用模态框的标题，aria-hidden=true保持模态框在触发前窗口不可见  -->
								<div class="modal-dialog">
									<!--  显示模态框对话框模型（若不写下一个div则没有颜色）  -->
									<div class="modal-content">
										<!--  显示模态框白色背景，所有内容都写在这个div里面  -->

										<div class="btn-info modal-header">
											<!--  模态框标题  -->
											<button type="button" class="close" data-dismiss="modal">&times;</button>
											<!--  关闭按钮  -->
											<h4>密码修改</h4>
											<!--  标题内容  -->
										</div>

										<div class="modal-body">
											<!--  模态框内容，我在此处添加一个表单 -->
											<form class="form-horizontal" role="form">
												<div class="form-group">
													<label for="userName" class="col-sm-3 control-label">用户名：</label>
													<div class="col-sm-5">
														<input type="text" id="userName" name="userName"
															class="form-control well" value="${user.userName }"   /> 
													</div>
													<span id="s1"></span>
												</div>
												<div class="form-group">
													<label for="userName" class="col-sm-3 control-label">原密码：</label>
													<div class="col-sm-5">
														<input type="password" id="oldPassword" name="oldPassword"
															class="form-control well"  placeholder="请输入原始密码" /> 
													</div>
													<span id="s2"></span>
												</div>
												<div class="form-group">
													<label for="userName" class="col-sm-3 control-label">新密码：</label>
													<div class="col-sm-5">
														<input type="password" id="newPassword" name="newPassword"
															class="form-control well"  placeholder="请输入新密码" /> 
													</div>
												</div>
												<div class="form-group">
													<label for="userName" class="col-sm-3 control-label">确认新密码：</label>
													<div class="col-sm-5">
														<input type="password" id="rePassword" name="rePassword"
															class="form-control well"   placeholder="请确认新密码" /> 
													</div>
													<span id="s4"></span>
												</div>

											</form>
										</div>

										<div class="modal-footer">
											<!--  模态框底部样式，一般是提交或者确定按钮 -->
											<button  class="btn btn-info" onclick="changePassword()" id="sChange">确定修改</button>
											<button type="button" class="btn btn-default"
												data-dismiss="modal">取消</button>
										</div>

									</div>
									<!-- /.modal-content -->
								</div>
							</div>
							<!-- /.modal -->
						</form>
				
				
				<div class="span12">
					<!-- alan_18.2.7_start_update_style -->
					<table class="table table-striped table-bordered table-hover dataTables-example">
						<thead>
							<tr bgcolor="#87CEEB">
								<th>表名</th>
								<th>创建人</th>
								<th>所属项目</th>
							</tr> 
						</thead>
						<tbody>
							<c:forEach items="${userTableList}" var="userTable">

								<tr class="gradeX">
									<td><a>${userTable.tableName}</a></td>
									<td>${userTable.creator}</td>
									<td>${userTable.projectName}</td>
									
								</tr>

							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</body>
<!-- <script type="text/javascript">
		var a1 = $("#userName").val();
		var a2 = $("#oldPassword").val();
		var a3 = $("#newPassword").val();
		var a4 = $("#rePassword").val();

		$(function(){
			
			
			if(a1 == "" ||a2 == "" ||a3 == "" ||a4 == "" ){
				$("#sChange").attr("disabled",true);
			}
			
			$("#oldPassword").blur(function(){
				var userName = $("#userName").val();
				var password = $(this).val();
				
				if(userName != ""){
					$.post("${ pageContext.request.contextPath }/user/checkPassword",{"userName":userName,"password":password},function(data){
						
		 				if(data == 1){
		 					 $("#s2").html("<font color='green'> </font>"); 
		 					$("#sChange").attr("disabled",false);
		 				}else if(data == 2){
		 					$("#s2").html("<font color='red'>您输入的密码不正确</font>");
		 					$("#sChange").attr("disabled",true);
			 			}
			 		});
				}else{
						$("#s2").html("<font color='red'>原密码不能为空</font>");
						$("#sChange").attr("disabled",true);
				}
			});
			
			$("#rePassword").blur(function(){
				var password = $("#newPassword").val();
				var rePassword = $(this).val();
				
				
				if(password != rePassword){
					$("#s4").html("<font color='red'>两次密码输入不一致</font>");
					$("#sChange").attr("disabled",true);
				}else{
					$("#s4").html("<font color='red'></font>");
					$("#sChange").attr("disabled",false);
				}
			});
			
			
				
		});
		
		

		function changePassword(){
			if(a3 == "" ){
				alert("请输入要修改的密码");
			}else{
			
				$.ajax({  
			        type: "POST",  
			        url:"${ pageContext.request.contextPath }/user/changePassword",  
			        data:$('#myForm').serialize(),// 序列化表单值  
			        dataType: "json",
			        success: function (data) {
			            alert("修改密码成功");
			           
					},
					async: true,
					cache: false
					}); 
			}
		}

	function deleteProject(obj) {
	    
	    var param = "projectId=" + obj;
	    if (confirm("确认删除"+param+"吗？")){
			$.ajax({
				url: "${base}/project/delete",
				data: {projectId:obj},
				dataType: "json",
				type: "POST",
				success: function (data) {
					
					 location.reload(); 
				},
				async: true,
				cache: false
				});
	    }
	}
	
	
	$(".tr").bind("mouseover", function() {
		$(this).css("background-color", "#eeeeee");
	})
	$(".tr").bind("mouseout", function() {
		$(this).css("background-color", "#ffffff");
	})
</script> -->
</html>


